package com.wzt.lianfirecontrol.activity;

import android.app.Activity;

import java.util.ArrayList;

public class ActivityCollecter {

    private static ArrayList<Activity> baseActivities = new ArrayList<>();

    public static void addActivity(Activity activity){
        baseActivities.add(activity);
    }

    //将某一个Activity移除
    public static void removeActivity(Activity activity){
        baseActivities.remove(activity);
    }

    public static void removeAllActivitys(){
        baseActivities.clear();
    }

    public static void finishAllActivitys(){
        for (Activity activity:baseActivities){
            if (activity instanceof BaseActivity){
                ((BaseActivity)activity).isExitLogin = true;
            }
            activity.finish();
        }
        baseActivities.clear();
    }

    public static Activity getCurrentActivity(){
        if (baseActivities.size() > 0) {
            return baseActivities.get(baseActivities.size() - 1);
        }else {
            return null;
        }
    }
}
